package com.diver.flinkdemo.readervo;

import lombok.Data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * Created with IntelliJ IDEA.
 *
 * @Description: 终端模板
 * @Author: zhangB
 * @Date: 2023/3/2 13:25
 */
@Data
public class TerminalTemplate {

    /**
     * 终端模板前缀
     */
    public final static String TERMINAL_TEMPLATE_PREFIX = "TerminalTemplate-";

    /**
     * 终端模板
     */
    public static Map<String, TerminalTemplate> terminalTemplateMap = new HashMap<>();


    /**
     * 下发通用模板
     */
    private CommonTemplateDefinition commonTemplate;

    /**
     * 设备参数列表
     */
    private List<TemplateParamsDefinition> paramList = new ArrayList();


    /**
     * 根据id获取个人终端设备下发参数
     * @param id
     * @return
     */
    public static TemplateParamsDefinition getParamById(String id, String terminalSeries){
        TerminalTemplate templateDefinition = TerminalTemplate.terminalTemplateMap.get(TERMINAL_TEMPLATE_PREFIX +terminalSeries+TemplateDefinition.FILE_TEMPLATE_SUFFIX);
        List<TemplateParamsDefinition> collect = templateDefinition.getParamList().stream().filter(o -> id.equals(o.getId())).collect(Collectors.toList());
        return collect.get(0);
    }


}
